package com.iwuke.dance.wallet.e_coin.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.iwuke.dance.R;
import com.iwuke.dance.util.GlideUtil;
import com.iwuke.dance.wallet.bean.ListETransactionRecordBean;

import java.util.List;

import androidx.annotation.NonNull;

/**
 * @author: 魏从响
 * @date: 2025/9/18
 */
public class ItemECoinDetailsAdapter extends BaseQuickAdapter<ListETransactionRecordBean.TransactionsBean, BaseViewHolder> {

    private final Context context;

    public ItemECoinDetailsAdapter(Context context, int adapterItemECoinDetails, List<ListETransactionRecordBean.TransactionsBean> strings) {
        super(adapterItemECoinDetails, strings);
        this.context = context;
    }

    @Override
    protected void convert(@NonNull BaseViewHolder baseViewHolder, ListETransactionRecordBean.TransactionsBean s) {
        TextView tv_item_title = baseViewHolder.findView(R.id.tv_item_title);//给主播赠送了小心心
        TextView tv_e_coin = baseViewHolder.findView(R.id.tv_e_coin);//-1
        ImageView img_avatar = baseViewHolder.findView(R.id.img_avatar);//头像
        RelativeLayout rlt_nickname = baseViewHolder.findView(R.id.rlt_nickname);//头像、昵称、礼物是否显示
        TextView tv_nickname = baseViewHolder.findView(R.id.tv_nickname);//昵称 大帅哥
        ImageView img_gift = baseViewHolder.findView(R.id.img_gift);//礼物图标
        TextView tv_quantity = baseViewHolder.findView(R.id.tv_quantity);//礼物数量
        View v_show = baseViewHolder.findView(R.id.v_show);//上边距
        TextView tv_item_time = baseViewHolder.findView(R.id.tv_item_time);//每个子条目的时间
        TextView tv_remaining_e_coins = baseViewHolder.findView(R.id.tv_remaining_e_coins);//剩余E币

//        LogUtil.logD("条目id",String.valueOf(s.id));

        tv_item_title.setText(s.giftName);//给主播赠送了小心心  标题
        switch (s.txnType){
            case 1:
                //支出
                tv_e_coin.setText("-"+s.amount);//-1
                tv_e_coin.setTextColor(context.getColor(R.color.color_000));
                break;

            case 2:
                //收入
                tv_e_coin.setText("+"+s.amount);//+1
                tv_e_coin.setTextColor(context.getColor(R.color.color_f0));
                break;
        }

        tv_item_time.setText(s.createTime);//每个子条目的时间
        tv_remaining_e_coins.setText("剩余E币："+s.ebalanceAfter);//剩余E币

        if (s.txnSubType.equals("1.1")){
            //微信充值
            rlt_nickname.setVisibility(View.GONE);
            v_show.setVisibility(View.VISIBLE);
        }else if (s.txnSubType.equals("3.1")){
            rlt_nickname.setVisibility(View.VISIBLE);
            v_show.setVisibility(View.GONE);
            //送礼物
            GlideUtil.setImageView(context,s.relatedUserPortrait,img_avatar);//头像
            tv_nickname.setText(s.relatedUserName);//昵称 大帅哥
            GlideUtil.setImageView(context,s.giftPortrait,img_gift);//礼物图标
            tv_quantity.setText(String.valueOf(s.num));//礼物数量
        }





    }
}
